<template>
  <div>
    <van-nav-bar
      title="设置昵称"
      left-text="取消"
      right-text="完成"
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <div class="prop">
      <van-field
        v-model.trim="message"
        rows="2"
        autosize
        type="textarea"
        maxlength="11"
        placeholder="请输入昵称"
        show-word-limit
      />
    </div>
  </div>
</template>
<script>
import { editUserinfo_api } from "@/api/user.js";
export default {
  props: {
    // nickName: { type: [String, Number] },
  },
  data() {
    return {
      message: "",
    };
  },
  methods: {
    onClickLeft() {
      this.$emit("nickfunc");
    },
    async onClickRight() {
      const { data: res } = await editUserinfo_api({ name: this.message });
      console.log(res);
      //   this.message = res.data.name;
      this.$emit("nickfunc", res.data.name);
    },
  },
};
</script>
<style lang='less' scoped>
.prop {
  margin: 20px;
}
</style>